package Test;
import DBLayer.*;
import ModelLayer.*;

import org.junit.Before;
import org.junit.Test;

public class TestDBProduct {	
	private DBProduct dbProduct;
	private DBSupplier dbSupplier;	

	@Before
	public void setUp() throws Exception {
		dbProduct = new DBProduct();
		dbSupplier = new DBSupplier();
	}

	@Test
	public void testCreateSupplier() throws Exception {
		int id = 1;
		String name = "Dennis";
		String address = "address";
		String country = "Danmark";
		String phoneNo = "99887766";
		String email = "email";
		Supplier sup = new Supplier(id, name, address, country, phoneNo, email);

		dbSupplier.insertSupplier(sup);
	}
	
	@Test
	public void testUpdateSupplier() throws Exception {
		int id = 1;
		String name = "Dennis";
		String address = "Sofiendalsvej";
		String country = "Danmark";
		String phoneNo = "99887766";
		String email = "email";
		Supplier sup = new Supplier(id, name, address, country, phoneNo, email);

		dbSupplier.updateSupplier(sup);
	}
	
	@Test
	public void testCreateProduct() throws Exception {
		
		int productId = 1;
		String name = "Cowboyhat";
		Double purchasePrice = 299.99;
		Double salesPrice = 500.00;
		Double rentPrice = 100.00;
		String countryOfOrigin = "Cowbyderland";
		int minStock = 5;
		int stockAmount = 4;
		Supplier supplier = dbSupplier.searchSupplier("Dennis");
		String size = "xl";
		String colour = "red";
		Clothing c = new Clothing(productId, name, purchasePrice, salesPrice, rentPrice, countryOfOrigin, minStock, stockAmount, supplier, size, colour);
		
		dbProduct.insertProduct(c);
	}
	@Test
	public void updateProduct() throws Exception {
		int productId = 1;
		String name = "Cowboyhat";
		Double purchasePrice = 299.99;
		Double salesPrice = 500.00;
		Double rentPrice = 100.00;
		String countryOfOrigin = "Cowbyderland";
		int minStock = 5;
		int stockAmount = 4;
		Supplier supplier = dbSupplier.searchSupplier("Dennis");
		String size = "l";
		String colour = "sort";
		Clothing c = new Clothing(productId, name, purchasePrice, salesPrice, rentPrice, countryOfOrigin, minStock, stockAmount, supplier, size, colour);
		
		dbProduct.updateProduct(c);
	}
	
	@Test
	public void testDeleteProductAndSupplier() throws Exception {
		
		Product p = dbProduct.searchProduct("Cowboyhat");
		dbProduct.deleteProduct(p);
		Supplier sup = dbSupplier.searchSupplier("Dennis");
		dbSupplier.deleteSupplier(sup);
	}
}
